import express from 'express';
import { getCategories, getCategory, createCategory, updateCategory, deleteCategory } from '../controllers/categoryController';
import { auth, checkRole } from '../middlewares/auth';

const router = express.Router();

// 获取所有分类
router.get('/', auth, getCategories);

// 获取单个分类
router.get('/:id', auth, getCategory);

// 创建分类
router.post('/', auth, checkRole(['admin']), createCategory);

// 更新分类
router.put('/:id', auth, checkRole(['admin']), updateCategory);

// 删除分类
router.delete('/:id', auth, checkRole(['admin']), deleteCategory);

export default router; 